import { InExShopItem } from "./InExShopItem";
import { ItemButton } from "./ItemButton";
import { ResFileConst } from "../../resource/ResFileConst";
import { ObjCreate } from "../common/ObjCreate";
import { ItemData } from "../../resource/info/ItemData";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
type int = number;
//class InExShopPetEggItem
    
    export  class InExShopPetEggItem extends InExShopItem
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            this._btnBg = new Object /* flash.display.Bitmap */();
            addChild(this._btnBg);
            this._btnEgg = new ItemButton();
            this._btnEgg.width = 106;
            this._btnEgg.height = 104;
            this._btnEgg.styleName = ResFileConst.InExPetEgg;
            this.addChild(this._btnEgg);
            _btnPrice = ObjCreate.createGLoadedButton(ResFileConst.InExbtn, -30, 70, 45, 33, this);
            createUnitIcon(7, 78);
            return;
        }

        public /* override */ updatePriceBtnStyle(arg1: string, arg2: int, arg3: int): void
        {
            if (_btnPrice) 
            {
                _btnPrice.styleName = arg1;
                _btnPrice.width = arg2;
                _btnPrice.height = arg3;
                if (arg2 > 50) 
                {
                    _btnPrice.x = 10;
                    _unitIconBitmap.x = 73;
                }
                else 
                {
                    _btnPrice.x = -30;
                    _unitIconBitmap.x = 7;
                }
                if (arg3 >= 40) 
                {
                    _btnPrice.y = 90;
                    _unitIconBitmap.y = 105;
                }
                else 
                {
                    _btnPrice.y = 70;
                    _unitIconBitmap.y = 78;
                }
            }
            return;
        }

        protected /* override */ updateView(): void
        {
            if (_shopItem) 
            {
                _btnPrice.label = _shopItem.price.toString();
                this._btnEgg.itemData = new ItemData(_shopItem.itemCode);
                updateUnitIcon();
                this.updateItemButton();
                LoaderHelp.addResCallBack(ResFileConst.IntegralShop, this.onLoadedHandler);
            }
            else 
            {
                _btnPrice.label = "";
                this._btnEgg.itemData = null;
            }
            return;
        }

        /* internal  */updateItemButton(): void
        {
            if (_shopItem && _shopItem.shopId == 190000) 
            {
                this._btnEgg.styleName = ResFileConst.InExPetEgg;
            }
            else if (_shopItem && _shopItem.shopId == 200000) 
            {
                this._btnEgg.styleName = ResFileConst.InExStoneBtn;
            }
            else if (_shopItem && _shopItem.shopId == 310000) 
            {
                this._btnEgg.styleName = ResFileConst.InExBigCBtn31;
            }
            return;
        }

        /* internal  */onLoadedHandler(): void
        {
            if (_shopItem && _shopItem.shopId == 190000) 
            {
                this._btnBg.x = 25;
                this._btnEgg.x = 20;
                this._btnBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.ISExBigBg0);
            }
            else if (_shopItem && (_shopItem.shopId == 200000 || _shopItem.shopId == 310000)) 
            {
                this._btnBg.x = -10;
                this._btnEgg.x = -10;
                _btnPrice.x = -0;
                _unitIconBitmap.x = 63;
                this._btnBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.ISExBigBg1);
            }
            return;
        }

        protected /* var */_btnEgg: ItemButton;

        protected /* var */_btnBg: Object /* flash.display.Bitmap */;
    }
